<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="./js/jquery.min.js"></script>
    <title>Document</title>
</head>

<body>
    <button class="btn">发送请求</button>

    <!-- <script>
        function getPromise(obj={}) {
            return new Promise((resolve, reject) => {
                $.ajax({
                    url:obj.url,
                    type:obj.type,
                    data:obj.data,
                    success: function (res) {
                        resolve(res)
                    },
                    error: function (err) {
                        reject(err)
                    }
                })
            })
        }

        $('.btn').on('click',function(){
            getPromise({
                url:'/',
                type:'get',
                data:{}
            }).then(res => {
                console.log(res);
            })
        })
    </script> -->
    <script>
        $('.btn').on('click', function () {
            fetch('/test').then(res => res.json()).then(result => {
                console.log(result);
            })
        })
    </script>
</body>

</html>